<template>
  <div>
    <el-form-item>
      <span slot="label">
        选择组织架构
        <el-tooltip class="item" content="支持选择系统组织架构作为评选对象" effect="dark" placement="top-start">
          <i class="el-icon-question" />
        </el-tooltip>
      </span>
      <el-switch v-model="activeData.isSelectOrganization" />
    </el-form-item>
    <matrix-option :active-data="activeData" />
    <el-divider>下拉选项-分值</el-divider>
    <draggable :animation="340" :list="activeData.options" group="selectItem" handle=".option-drag">
      <div v-for="(item, index) in activeData.options" :key="index" class="select-item">
        <div class="select-line-icon option-drag">
          <i class="el-icon-s-operation" />
        </div>
        <el-input v-model="item.label" placeholder="选项名" size="small" />
        <el-input-number v-model="item.score" placeholder="分值" size="small" :controls="false" />
        <div class="close-btn select-line-icon" @click="activeData.config.options.splice(index, 1)">
          <i class="el-icon-remove-outline" />
        </div>
      </div>
    </draggable>
    <div>
      <el-button
        icon="el-icon-circle-plus-outline"
        style="padding-bottom: 0; margin-left: 20px"
        type="text"
        @click="addSelectItem"
      >
        添加选项
      </el-button>
    </div>
  </div>
</template>
<script>
import MatrixOption from './matrix'

import draggable from 'vuedraggable'

export default {
  name: 'ConfigItemMatrixDropdown',
  components: {
    MatrixOption,
    draggable
  },
  props: ['activeData'],
  data() {
    return {}
  },
  methods: {
    handleChange() {
      this.$set(this.activeData.config, 'defaultValue', {})
    },
    addSelectItem() {
      this.activeData.options.push({
        label: '选项',
        score: 1
      })
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../../../assets/styles/config/options.scss';
</style>
